/*
* @Author: majingyu
* @Date:   2017-05-28 21:13:02
* @Last Modified by:   majingyu
* @Last Modified time: 2017-06-08 10:33:58
*/

import React, { Component }from 'react';
import { connect } from 'react-redux';
import OrderList from 'components/myOrder.jsx';
import { submitCommont } from 'action/commont.js';
import 'css/commont.less';
 
class Commont extends Component{
    constructor(props) {
        super(props);
         this.state={
            commont:''
         }
    }  
    getValue(e){
        this.setState(Object.assign({},this.state,{
            commont: e.target.value
        }))
    }
    submit(){
        this.props.submitCommont(this.state.commont);
    }
    render(){
        return(
            <div className="content">
                <div className="commont-info">
                    <textarea className="commont-text" rows="5" cols="50" placeholder="请填写真实评论，以备他人参考" onChange={(e)=>this.getValue(e)}>
                    </textarea>
                    <a className="btn submit" onClick={()=>this.submit()}>{this.props.commont.commontText}</a>
                </div>
            </div>
        );
    }
}
const commontData = (state) => {
    return {
        commont: state.commont
    }
}
let dispatchHandle = (dispatch, getState) => {
    return {
        submitCommont(value){
            dispatch(submitCommont(value)) 
        }
        
    }
    
}
let visibileEvaliate= connect(commontData,dispatchHandle)(Commont);


export default visibileEvaliate;